<template>
	<!-- 扩散设置 -->
	<div class="page-wrap">
		<div class="page-content p-0">
			<div class="page-column p-0">
				<div class="page-form p-x-0">
					<el-form
						:model="ruleForm"
						:rules="rules"
						label-position="left"
						label-width="140px"
						ref="form"
						label-suffix="："
					>
						<el-row>
							<el-col :span="24">
								<el-form-item label="剂量计算模式" prop="DISPERSION">
									<select-para
										class="mediumForm"
										v-model="ruleForm.DISPERSION"
										:label.sync="ruleForm.DISPERSIONName"
										:options="DISPERSIONoptions"
										defaultPara
										@change="DISPERSIONChange"
									></select-para>
								</el-form-item>
								<div v-if="this.ruleForm.DISPERSION =='0'" :style="{'margin-bottom':'20px'}">
									<div class="operation">
										<el-button type="primary" size="small" @click="exportExcel(1)">
											<img :style="{width: '12px',height: '12px'}" src="/img/basic/daochu.png" alt />
											&nbsp;导出
										</el-button>
										<el-button type="primary" size="small" @click="daoru(1)">
											<img :style="{width: '12px',height: '12px'}" src="/img/basic/daoru.png" alt />
											&nbsp;导入
										</el-button>
										<input
											ref="file1"
											id="img-upload"
											class="selectFile"
											type="file"
											@change="importf(this)"
											accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
										/>
									</div>
									<el-table ref="multipleTable" :data="ruleForm.DISPERSIONtab" tooltip-effect="dark" border>
										<el-table-column prop="name" label="因子等级" align="center" min-width="120"></el-table-column>
										<el-table-column label="稳定度等级" align="left">
											<el-table-column prop="item1" label="1" align="center" min-width="120">
												<template slot-scope="scope">
													<el-form-item
														label-width="0px"
														:prop="'DISPERSIONtab.'+scope.$index+'.item1'"
														:rules="rules.item1"
													>
														<el-input
															oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,20})?).*$/g, '$1')"
															class="smalllForm"
															v-model="scope.row.item1"
														></el-input>
													</el-form-item>
												</template>
											</el-table-column>
											<el-table-column prop="item2" label="2" align="center" min-width="120">
												<template slot-scope="scope">
													<el-form-item
														label-width="0px"
														:prop="'DISPERSIONtab.'+scope.$index+'.item2'"
														:rules="rules.item2"
													>
														<el-input
															minlength="1"
															maxlength="20"
															oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,20})?).*$/g, '$1')"
															class="smalllForm"
															v-model="scope.row.item2"
														></el-input>
													</el-form-item>
												</template>
											</el-table-column>
											<el-table-column prop="item3" label="3" align="center" min-width="120">
												<template slot-scope="scope">
													<el-form-item
														label-width="0px"
														:prop="'DISPERSIONtab.'+scope.$index+'.item3'"
														:rules="rules.item3"
													>
														<el-input
															minlength="1"
															maxlength="20"
															oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,20})?).*$/g, '$1')"
															class="smalllForm"
															v-model="scope.row
																		.item3
																"
														></el-input>
													</el-form-item>
												</template>
											</el-table-column>
											<el-table-column prop="item4" label="4" align="center" min-width="120">
												<template slot-scope="scope">
													<el-form-item
														label-width="0px"
														:prop="'DISPERSIONtab.'+scope.$index+'.item4'"
														:rules="rules.item4"
													>
														<el-input
															minlength="1"
															maxlength="20"
															oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,20})?).*$/g, '$1')"
															class="smalllForm"
															v-model="
																	scope.row
																		.item4
																"
														></el-input>
													</el-form-item>
												</template>
											</el-table-column>
											<el-table-column prop="item5" label="5" align="center" min-width="120">
												<template slot-scope="scope">
													<el-form-item
														label-width="0px"
														:prop="'DISPERSIONtab.'+scope.$index+'.item5'"
														:rules="rules.item5"
													>
														<el-input
															minlength="1"
															maxlength="20"
															oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,20})?).*$/g, '$1')"
															class="smalllForm"
															v-model="scope.row.item5"
														></el-input>
													</el-form-item>
												</template>
											</el-table-column>
											<el-table-column prop="item6" label="6" align="center" min-width="120">
												<template slot-scope="scope">
													<el-form-item
														label-width="0px"
														:prop="'DISPERSIONtab.'+scope.$index+'.item6'"
														:rules="rules.item6"
													>
														<el-input
															minlength="1"
															maxlength="20"
															oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,20})?).*$/g, '$1')"
															class="smalllForm"
															v-model="scope.row.item6"
														></el-input>
													</el-form-item>
												</template>
											</el-table-column>
										</el-table-column>
									</el-table>
								</div>
							</el-col>
						</el-row>
						<el-row>
							<el-col :span="24" v-if="this.ruleForm.DISPERSION =='1'">
								<el-form-item v-if="this.ruleForm.DISPERSION == '1'" label="扩散系数距离个数" prop="NUM_DIST001">
									<el-input
										class="mediumForm"
										@input="NUM_DIST001Change"
										v-model.number="ruleForm.NUM_DIST001"
									></el-input>
								</el-form-item>
								<div v-if="this.ruleForm.NUM_DIST001>0 || this.ruleForm.DISPERSION > '0'">
									<div class="operation">
										<el-button type="primary" size="small" @click="exportExcel(2)">
											<img :style="{width: '12px',height: '12px'}" src="/img/basic/daochu.png" alt />
											&nbsp;导出
										</el-button>
										<el-button type="primary" size="small" @click="daoru(2)">
											<img :style="{width: '12px',height: '12px'}" src="/img/basic/daoru.png" alt />
											&nbsp;导入
										</el-button>
										<input
											ref="file2"
											id="img-upload"
											class="selectFile"
											type="file"
											@change="importf(this)"
											accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
										/>
									</div>
									<el-table
										ref="multipleTable"
										:data="ruleForm.DIST_DISTANCEtab"
										tooltip-effect="dark"
										border
									>
										<el-table-column prop="index" label="扩散距离编号" align="center" width="120"></el-table-column>
										<el-table-column label="稳定度等级" align="left">
											<el-table-column prop="sionitem1" label="A" align="center" min-width="120">
												<template slot-scope="scope">
													<el-form-item
														label-width="0px"
														:rules="rules.sionitem1"
														:prop="'DIST_DISTANCEtab.'+scope.$index+'.sionitem1'"
													>
														<el-input
															minlength="1"
															maxlength="20"
															oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,20})?).*$/g, '$1')"
															class="smalllForm"
															v-model="scope.row.sionitem1"
														></el-input>
													</el-form-item>
												</template>
											</el-table-column>
											<el-table-column prop="sionitem2" label="B" align="center" min-width="120">
												<template slot-scope="scope">
													<el-form-item
														label-width="0px"
														:rules="rules.sionitem2"
														:prop="'DIST_DISTANCEtab.'+scope.$index+'.sionitem2'"
													>
														<el-input
															minlength="1"
															maxlength="20"
															oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,20})?).*$/g, '$1')"
															class="smalllForm"
															v-model="scope.row.sionitem2"
														></el-input>
													</el-form-item>
												</template>
											</el-table-column>
											<el-table-column prop="sionitem3" label="C" align="center" min-width="120">
												<template slot-scope="scope">
													<el-form-item
														label-width="0px"
														:rules="rules.sionitem3"
														:prop="'DIST_DISTANCEtab.'+scope.$index+'.sionitem3'"
													>
														<el-input
															minlength="1"
															maxlength="20"
															oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,20})?).*$/g, '$1')"
															class="smalllForm"
															v-model="scope.row.sionitem3"
														></el-input>
													</el-form-item>
												</template>
											</el-table-column>
											<el-table-column prop="sionitem4" label="D" align="center" min-width="120">
												<template slot-scope="scope">
													<el-form-item
														label-width="0px"
														:rules="rules.sionitem4"
														:prop="'DIST_DISTANCEtab.'+scope.$index+'.sionitem4'"
													>
														<el-input
															minlength="1"
															maxlength="20"
															oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,20})?).*$/g, '$1')"
															class="smalllForm"
															v-model="scope.row.sionitem4"
														></el-input>
													</el-form-item>
												</template>
											</el-table-column>
											<el-table-column prop="sionitem5" label="E" align="center" min-width="120">
												<template slot-scope="scope">
													<el-form-item
														label-width="0px"
														:rules="rules.sionitem5"
														:prop="'DIST_DISTANCEtab.'+scope.$index+'.sionitem5'"
													>
														<el-input
															minlength="1"
															maxlength="20"
															oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,20})?).*$/g, '$1')"
															class="smalllForm"
															v-model="scope.row.sionitem5"
														></el-input>
													</el-form-item>
												</template>
											</el-table-column>
											<el-table-column prop="sionitem6" label="F" align="center" min-width="120">
												<template slot-scope="scope">
													<el-form-item
														label-width="0px"
														:rules="rules.sionitem6"
														:prop="'DIST_DISTANCEtab.'+scope.$index+'.sionitem6'"
													>
														<el-input
															minlength="1"
															maxlength="20"
															oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,20})?).*$/g, '$1')"
															class="smalllForm"
															v-model="scope.row.sionitem6"
														></el-input>
													</el-form-item>
												</template>
											</el-table-column>
										</el-table-column>
									</el-table>
								</div>
								<div v-if="this.ruleForm.NUM_DIST001>0 ||this.ruleForm.DISPERSION > '0'">
									<div class="operation">
										<el-button type="primary" size="small" @click="exportExcel(3)">
											<img :style="{width: '12px',height: '12px'}" src="/img/basic/daochu.png" alt />
											&nbsp;导出
										</el-button>
										<el-button type="primary" size="small" @click="daoru(3)">
											<img :style="{width: '12px',height: '12px'}" src="/img/basic/daoru.png" alt />
											&nbsp;导入
										</el-button>
										<input
											ref="file3"
											id="img-upload"
											class="selectFile"
											type="file"
											@change="importf(this)"
											accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
										/>
									</div>
									<el-table ref="multipleTable" :data="ruleForm.DIST_SIGYtab" tooltip-effect="dark" border>
										<el-table-column prop="index" label="Y方向扩散距离编号" align="center" width="120"></el-table-column>
										<el-table-column label="稳定度等级" align="left">
											<el-table-column prop="SIGYitem1" label="A" align="center" min-width="120">
												<template slot-scope="scope">
													<el-form-item
														label-width="0px"
														:rules="rules.SIGYitem1"
														:prop="'DIST_SIGYtab.'+scope.$index+'.SIGYitem1'"
													>
														<el-input
															minlength="1"
															maxlength="20"
															oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,20})?).*$/g, '$1')"
															class="smalllForm"
															v-model="scope.row.SIGYitem1"
														></el-input>
													</el-form-item>
												</template>
											</el-table-column>
											<el-table-column prop="SIGYitem2" label="B" align="center" min-width="120">
												<template slot-scope="scope">
													<el-form-item
														label-width="0px"
														:rules="rules.SIGYitem2"
														:prop="'DIST_SIGYtab.'+scope.$index+'.SIGYitem2'"
													>
														<el-input
															minlength="1"
															maxlength="20"
															oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,20})?).*$/g, '$1')"
															class="smalllForm"
															v-model="scope.row.SIGYitem2"
														></el-input>
													</el-form-item>
												</template>
											</el-table-column>
											<el-table-column prop="SIGYitem3" label="C" align="center" min-width="120">
												<template slot-scope="scope">
													<el-form-item
														label-width="0px"
														:rules="rules.SIGYitem3"
														:prop="'DIST_SIGYtab.'+scope.$index+'.SIGYitem3'"
													>
														<el-input
															minlength="1"
															maxlength="20"
															oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,20})?).*$/g, '$1')"
															class="smalllForm"
															v-model="scope.row.SIGYitem3"
														></el-input>
													</el-form-item>
												</template>
											</el-table-column>
											<el-table-column prop="SIGYitem4" label="D" align="center" min-width="120">
												<template slot-scope="scope">
													<el-form-item
														label-width="0px"
														:rules="rules.SIGYitem4"
														:prop="'DIST_SIGYtab.'+scope.$index+'.SIGYitem4'"
													>
														<el-input
															minlength="1"
															maxlength="20"
															oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,20})?).*$/g, '$1')"
															class="smalllForm"
															v-model="scope.row.SIGYitem4"
														></el-input>
													</el-form-item>
												</template>
											</el-table-column>
											<el-table-column prop="SIGYitem5" label="E" align="center" min-width="120">
												<template slot-scope="scope">
													<el-form-item
														label-width="0px"
														:rules="rules.SIGYitem5"
														:prop="'DIST_SIGYtab.'+scope.$index+'.SIGYitem5'"
													>
														<el-input
															minlength="1"
															maxlength="20"
															oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,20})?).*$/g, '$1')"
															class="smalllForm"
															v-model="scope.row.SIGYitem5"
														></el-input>
													</el-form-item>
												</template>
											</el-table-column>
											<el-table-column prop="SIGYitem6" label="F" align="center" min-width="120">
												<template slot-scope="scope">
													<el-form-item
														label-width="0px"
														:rules="rules.SIGYitem6"
														:prop="'DIST_SIGYtab.'+scope.$index+'.SIGYitem6'"
													>
														<el-input
															minlength="1"
															maxlength="20"
															oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,20})?).*$/g, '$1')"
															class="smalllForm"
															v-model="scope.row.SIGYitem6"
														></el-input>
													</el-form-item>
												</template>
											</el-table-column>
										</el-table-column>
									</el-table>
								</div>
								<div
									v-if="this.ruleForm.NUM_DIST001>0 || this.ruleForm.DISPERSION > '0'"
									:style="{'margin-bottom':'20px'}"
								>
									<div class="operation">
										<el-button type="primary" size="small" @click="exportExcel(4)">
											<img :style="{width: '12px',height: '12px'}" src="/img/basic/daochu.png" alt />
											&nbsp;导出
										</el-button>
										<el-button type="primary" size="small" @click="daoru(4)">
											<img :style="{width: '12px',height: '12px'}" src="/img/basic/daoru.png" alt />
											&nbsp;导入
										</el-button>
										<input
											ref="file4"
											id="img-upload"
											class="selectFile"
											type="file"
											@change="importf(this)"
											accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
										/>
									</div>
									<el-table ref="multipleTable" :data="ruleForm.DIST_SIGZtab" tooltip-effect="dark" border>
										<el-table-column prop="index" label="Z方向扩散距离编号" align="center" width="120"></el-table-column>
										<el-table-column label="稳定度等级" align="left">
											<el-table-column prop="SIGitem1" label="A" align="center" min-width="120">
												<template slot-scope="scope">
													<el-form-item
														label-width="0px"
														:rules="rules.SIGitem1"
														:prop="'DIST_SIGZtab.'+scope.$index+'.SIGitem1'"
													>
														<el-input
															minlength="1"
															maxlength="20"
															oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,20})?).*$/g, '$1')"
															class="smalllForm"
															v-model="scope.row.SIGitem1"
														></el-input>
													</el-form-item>
												</template>
											</el-table-column>
											<el-table-column prop="SIGitem2" label="B" align="center" min-width="120">
												<template slot-scope="scope">
													<el-form-item
														label-width="0px"
														:rules="rules.SIGitem2"
														:prop="'DIST_SIGZtab.'+scope.$index+'.SIGitem2'"
													>
														<el-input
															minlength="1"
															maxlength="20"
															oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,20})?).*$/g, '$1')"
															class="smalllForm"
															v-model="scope.row.SIGitem2"
														></el-input>
													</el-form-item>
												</template>
											</el-table-column>
											<el-table-column prop="SIGitem3" label="C" align="center" min-width="120">
												<template slot-scope="scope">
													<el-form-item
														label-width="0px"
														:rules="rules.SIGitem3"
														:prop="'DIST_SIGZtab.'+scope.$index+'.SIGitem1'"
													>
														<el-input
															minlength="1"
															maxlength="20"
															oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,20})?).*$/g, '$1')"
															class="smalllForm"
															v-model="scope.row.SIGitem3"
														></el-input>
													</el-form-item>
												</template>
											</el-table-column>
											<el-table-column prop="SIGitem4" label="D" align="center" min-width="120">
												<template slot-scope="scope">
													<el-form-item
														label-width="0px"
														:rules="rules.SIGitem4"
														:prop="'DIST_SIGZtab.'+scope.$index+'.SIGitem4'"
													>
														<el-input
															minlength="1"
															maxlength="20"
															oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,20})?).*$/g, '$1')"
															class="smalllForm"
															v-model="scope.row.SIGitem4"
														></el-input>
													</el-form-item>
												</template>
											</el-table-column>
											<el-table-column prop="SIGitem5" label="E" align="center" min-width="120">
												<template slot-scope="scope">
													<el-form-item
														label-width="0px"
														:rules="rules.SIGitem5"
														:prop="'DIST_SIGZtab.'+scope.$index+'.SIGitem5'"
													>
														<el-input
															minlength="1"
															maxlength="20"
															oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,20})?).*$/g, '$1')"
															class="smalllForm"
															v-model="scope.row.SIGitem5"
														></el-input>
													</el-form-item>
												</template>
											</el-table-column>
											<el-table-column prop="SIGitem6" label="F" align="center" min-width="120">
												<template slot-scope="scope">
													<el-form-item
														label-width="0px"
														:rules="rules.SIGitem6"
														:prop="'DIST_SIGZtab.'+scope.$index+'.SIGitem6'"
													>
														<el-input
															minlength="1"
															maxlength="20"
															oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,20})?).*$/g, '$1')"
															class="smalllForm"
															v-model="scope.row.SIGitem6"
														></el-input>
													</el-form-item>
												</template>
											</el-table-column>
										</el-table-column>
									</el-table>
								</div>
							</el-col>
						</el-row>

						<el-row>
							<el-col :span="24">
								<el-form-item label="Y方向线型因子" prop="DPYSCALE001">
									<el-input class="mediumForm" v-model="ruleForm.DPYSCALE001"></el-input>
								</el-form-item>
								<el-form-item label="Z方向线型因子" prop="DPZSCALE001">
									<el-input class="mediumForm" v-model="ruleForm.DPZSCALE001"></el-input>
								</el-form-item>
							</el-col>
						</el-row>
					</el-form>
				</div>
				<div class="bottom-btn">
					<el-button type="primary" :loading="loading" @click="submitFun">下一步</el-button>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
import selectPara from "@/components/selectPara"
import commCheckbox from "@/components/commCheckbox"
import ImageCropper from "@/components/ImageCropper"
import FixBottomButton from "@/components/FixBottomButton"
import ueditor from "@/components/ueditor"
import textLength from "@/components/common/comp/textLength"
import { commPara } from "@/mixins/mixins"
import { mapState } from "vuex"
import { v001100, dome, selecttext } from "@/utils/verify.js"
import FileSaver from "file-saver"
import XLSX from "xlsx"
export default {
	name: "aboutUs",
	props: {
		batchid: String,
	},
	mixins: [commPara],
	components: {
		selectPara,
		ImageCropper,
		textLength,
		commCheckbox,
		FixBottomButton,
		ueditor,
	},

	data() {
		var DPZSCALE001 = (rule, value, callback) => {
			if (value < 0.01 || value > 100) {
				callback(new Error("输入范围为[0.01，100]"))
			} else {
				callback()
			}
		}
		var v350 = (rule, value, callback) => {
			if (value === "") {
				callback(new Error("输入值不能为空"))
			} else if (value < 3 || value > 50) {
				callback(new Error("输入范围为[3，50]"))
			} else {
				callback()
			}
		}
		return {
			type: "1",
			activeTab: "5",
			daorutype: "1",
			daochutype: "2",
			ruleForm: {
				regAmount: "",
				DISPERSION: "1",
				DISPERSIONName: "精细模式",
				DPYSCALE001: "1",
				DPZSCALE001: "1.27",
				NUM_DIST001: "0",
				DISPERSIONtab: [],
				DIST_SIGYtab: [],
				DIST_SIGZtab: [],
				DIST_DISTANCEtab: [], //扩散距离
			},
			DISPERSIONoptions: [
				{
					label: "简单模式",
					value: "0",
				},
				{
					label: "精细模式",
					value: "1",
				},
			],

			rules: {
				DISPERSION: [
					{
						validator: selecttext,
						trigger: ["change", "blur"],
					},
				],
				DPYSCALE001: [
					{
						validator: dome(0.01, 100),
						trigger: "change",
					},
				],
				DPZSCALE001: [
					{
						validator: dome(0.01, 100),
						trigger: "change",
					},
				],
				item1: [
					{
						validator: dome(1.6e-6, 10),
						trigger: "change",
					},
				],
				item2: [
					{
						validator: dome(1.6e-6, 10),
						trigger: "change",
					},
				],
				item3: [
					{
						validator: dome(1.6e-6, 10),
						trigger: "change",
					},
				],
				item4: [
					{
						validator: dome(1.6e-6, 10),
						trigger: "change",
					},
				],
				item5: [
					{
						validator: dome(1.6e-6, 10),
						trigger: "change",
					},
				],
				item6: [
					{
						validator: dome(1.6e-6, 10),
						trigger: "change",
					},
				],
				NUM_DIST001: [
					{
						validator: v350,
						trigger: "change",
					},
				],
				sionitem1: [
					{
						validator: dome(1.0, 1.0e8),
						trigger: "change",
					},
				],
				sionitem2: [
					{
						validator: dome(1.0, 1.0e8),
						trigger: "change",
					},
				],
				sionitem3: [
					{
						validator: dome(1.0, 1.0e8),
						trigger: "change",
					},
				],
				sionitem4: [
					{
						validator: dome(1.0, 1.0e8),
						trigger: "change",
					},
				],
				sionitem5: [
					{
						validator: dome(1.0, 1.0e8),
						trigger: "change",
					},
				],
				sionitem6: [
					{
						validator: dome(1.0, 1.0e8),
						trigger: "change",
					},
				],
				SIGYitem1: [
					{
						validator: dome(1.0e-6, 1.0e20),
						trigger: "change",
					},
				],
				SIGYitem2: [
					{
						validator: dome(1.0e-6, 1.0e20),
						trigger: "change",
					},
				],
				SIGYitem3: [
					{
						validator: dome(1.0e-6, 1.0e20),
						trigger: "change",
					},
				],
				SIGYitem4: [
					{
						validator: dome(1.0e-6, 1.0e20),
						trigger: "change",
					},
				],
				SIGYitem5: [
					{
						validator: dome(1.0e-6, 1.0e20),
						trigger: "change",
					},
				],
				SIGYitem6: [
					{
						validator: dome(1.0e-6, 1.0e20),
						trigger: "change",
					},
				],
				SIGitem1: [
					{
						validator: dome(1.0e-6, 1.0e20),
						trigger: "change",
					},
				],
				SIGitem2: [
					{
						validator: dome(1.0e-6, 1.0e20),
						trigger: "change",
					},
				],
				SIGitem3: [
					{
						validator: dome(1.0e-6, 1.0e20),
						trigger: "change",
					},
				],
				SIGitem4: [
					{
						validator: dome(1.0e-6, 1.0e20),
						trigger: "change",
					},
				],
				SIGitem5: [
					{
						validator: dome(1.0e-6, 1.0e20),
						trigger: "change",
					},
				],
				SIGitem6: [
					{
						validator: dome(1.0e-6, 1.0e20),
						trigger: "change",
					},
				],
			},
			loading: false,
		}
	},
	computed: {
		...mapState({
			basic_Data: (state) => state.token.basic_Data,
		}),
	},
	created() {
		// this.queryDetail()
	},
	mounted() {
		this.setData()
	},
	methods: {
		setData() {
			
			this.ruleForm.DISPERSION = this.basic_Data.DISPERSION.toString()
			if (this.basic_Data.DISPERSION == 0) {
				this.ruleForm.DISPERSIONtab = [
					{
						name: "σy线性因子",
						type: "DPCYSIGA",
						item1: "",
						item2: "",
						item3: "",
						item4: "",
						item5: "",
						item6: "",
					},
					{
						name: "σy指数因子",
						type: "DPCYSIGB",
						item1: "",
						item2: "",
						item3: "",
						item4: "",
						item5: "",
						item6: "",
					},
					{
						name: "σx线性因子",
						type: "DPCZSIGA",
						item1: "",
						item2: "",
						item3: "",
						item4: "",
						item5: "",
						item6: "",
					},
					{
						name: "σz指数因子",
						type: "DPCZSIGB",
						item1: "",
						item2: "",
						item3: "",
						item4: "",
						item5: "",
						item6: "",
					},
				]
				this.basic_Data.DPCYSIGA.forEach((item, index) => {
					let n = index + 1
					this.ruleForm.DISPERSIONtab[0]["item" + n] = item.toString()
				})
				this.basic_Data.DPCYSIGB.forEach((item, index) => {
					let n = index + 1
					this.ruleForm.DISPERSIONtab[1]["item" + n] = item.toString()
				})
				this.basic_Data.DPCZSIGA.forEach((item, index) => {
					let n = index + 1
					this.ruleForm.DISPERSIONtab[2]["item" + n] = item.toString()
				})
			
				this.basic_Data.DPCZSIGB.forEach((item, index) => {
					let n = index + 1
					this.ruleForm.DISPERSIONtab[3]["item" + n] = item.toString()
				}) 
			} else if (this.basic_Data.DISPERSION == 1) {
				this.ruleForm.NUM_DIST001 = this.basic_Data.NUM_DIST001
				this.ruleForm.DIST_DISTANCEtab = []
				this.ruleForm.DIST_SIGYtab = []
				this.ruleForm.DIST_SIGZtab = []
				for (
					let index = 1;
					index <= parseInt(this.basic_Data.NUM_DIST001);
					index++
				) {
					let tempdata = {
						index: index,
						sionitem1: "",
						sionitem2: "",
						sionitem3: "",
						sionitem4: "",
						sionitem5: "",
						sionitem6: "",
					}
					this.ruleForm.DIST_DISTANCEtab.push(tempdata)
					let tempdata2 = {
						index: index,
						SIGYitem1: "",
						SIGYitem2: "",
						SIGYitem3: "",
						SIGYitem4: "",
						SIGYitem5: "",
						SIGYitem6: "",
					}
					let tempdata3 = {
						index: index,
						SIGitem1: "",
						SIGitem2: "",
						SIGitem3: "",
						SIGitem4: "",
						SIGitem5: "",
						SIGitem6: "",
					}
					this.ruleForm.DIST_SIGYtab.push(tempdata2)
					this.ruleForm.DIST_SIGZtab.push(tempdata3)
				} 
				this.basic_Data.DIST_DISTANCE.forEach((item, index) => { 
					let i = index + 1
					item.forEach((it, n) => {
						this.ruleForm.DIST_DISTANCEtab[n][
							"sionitem" + i
						] = it.toString()
					})
				})

				this.basic_Data.DIST_SIGY.forEach((item, index) => {
					
					let i = index + 1
					item.forEach((it, n) => {
						this.ruleForm.DIST_SIGYtab[n][
							"SIGYitem" + i
						] = it.toString()
					})
				})

				this.basic_Data.DIST_SIGZ.forEach((item, index) => {
					let i = index + 1
					item.forEach((it, n) => {
						this.ruleForm.DIST_SIGZtab[n][
							"SIGitem" + i
						] = it.toString()
					})
				}) 
			}

			this.ruleForm.DPYSCALE001 = this.basic_Data.DPYSCALE001.toString()
			this.ruleForm.DPZSCALE001 = this.basic_Data.DPZSCALE001.toString()
		},
		exportExcel(val) {
			//导出Excel
			var that = this
			//要导出数据标题
			var arry = []
			if (val == 1) {
				arry = [["因子等级", "A", "B", "C", "D", "E", "F"]]
				// 要导出的历史数据
				that.ruleForm.DISPERSIONtab.map((a) => {
					var _arry = []
					_arry.push(a.name.toString())
					_arry.push(a.item1.toString())
					_arry.push(a.item2.toString())
					_arry.push(a.item3.toString())
					_arry.push(a.item4.toString())
					_arry.push(a.item5.toString())
					_arry.push(a.item6.toString())
					return _arry
				}).forEach((a) => {
					arry.push(a)
				})
			} else if (val == 2) {
				arry = [["扩散距离", "A", "B", "C", "D", "E", "F"]]
				that.ruleForm.DIST_DISTANCEtab.map((a) => {
					var _arry = []
					_arry.push(a.index.toString())
					_arry.push(a.sionitem1.toString())
					_arry.push(a.sionitem2.toString())
					_arry.push(a.sionitem3.toString())
					_arry.push(a.sionitem4.toString())
					_arry.push(a.sionitem5.toString())
					_arry.push(a.sionitem6.toString())
					return _arry
				}).forEach((a) => {
					arry.push(a)
				})
			} else if (val == 3) {
				arry = [["Y方向扩散距离", "A", "B", "C", "D", "E", "F"]]
				that.ruleForm.DIST_SIGYtab.map((a) => {
					var _arry = []
					_arry.push(a.index.toString())
					_arry.push(a.SIGYitem1.toString())
					_arry.push(a.SIGYitem2.toString())
					_arry.push(a.SIGYitem3.toString())
					_arry.push(a.SIGYitem4.toString())
					_arry.push(a.SIGYitem5.toString())
					_arry.push(a.SIGYitem6.toString())
					return _arry
				}).forEach((a) => {
					arry.push(a)
				})
			} else if (val == 4) {
				arry = [["Z方向扩散距离", "A", "B", "C", "D", "E", "F"]]
				that.ruleForm.DIST_SIGZtab.map((a) => {
					var _arry = []
					_arry.push(a.index.toString())
					_arry.push(a.SIGitem1.toString())
					_arry.push(a.SIGitem2.toString())
					_arry.push(a.SIGitem3.toString())
					_arry.push(a.SIGitem4.toString())
					_arry.push(a.SIGitem5.toString())
					_arry.push(a.SIGitem6.toString())
					return _arry
				}).forEach((a) => {
					arry.push(a)
				})
			}

			/* generate workbook object from table */
			var sheetHistory = XLSX.utils.aoa_to_sheet(arry)
			var workbook = XLSX.utils.book_new()
			XLSX.utils.book_append_sheet(workbook, sheetHistory, "稳定度")
			sheetHistory["!cols"] = [
				{ wpx: 150 },
				{ wpx: 90 },
				{ wpx: 90 },
				{ wpx: 90 },
				{ wpx: 90 },
				{ wpx: 90 },
				{ wpx: 90 },
			] //单元格列宽

			try {
				var wbOut = XLSX.write(workbook, {
					bookType: "xlsx",
					bookSST: true,
					type: "array",
				})
				FileSaver.saveAs(
					new Blob([wbOut], { type: "application/octet-stream" }),
					"稳定度.xlsx"
				)
			} catch (e) {
				if (typeof console !== "undefined") console.log(e, wbOut)
			}
		},
		importf(obj) {
			//导入数据
			let _this = this
			let inputDOM = this.$refs.inputer // 通过DOM取文件数据 
			this.file = event.currentTarget.files[0] 
			var rABS = false //是否将文件读取为二进制字符串
			var f = this.file
			var reader = new FileReader()
			//if (!FileReader.prototype.readAsBinaryString) {
			FileReader.prototype.readAsBinaryString = function (f) {
				var binary = ""
				var rABS = false //是否将文件读取为二进制字符串
				var pt = this
				var wb //读取完成的数据
				var outdata
				var reader = new FileReader()
				reader.onload = function (e) {
					var bytes = new Uint8Array(reader.result)
					var length = bytes.byteLength
					for (var i = 0; i < length; i++) {
						binary += String.fromCharCode(bytes[i])
					}
					var XLSX = require("xlsx")
					if (rABS) {
						wb = XLSX.read(btoa(fixdata(binary)), {
							//手动转化
							type: "base64",
						})
					} else {
						wb = XLSX.read(binary, {
							type: "binary",
						})
					}
					// outdata就是你想要的东西 excel导入的数据
					outdata = XLSX.utils.sheet_to_json(
						wb.Sheets[wb.SheetNames[0]]
					)
					// excel 数据再处理
					let arr = []  
					if (_this.type == "1") {
						outdata.map((v) => {
							let obj = {}
							obj.name = v.因子等级
							obj.item1 = v.A
							obj.item2 = v.B
							obj.item3 = v.C
							obj.item4 = v.D
							obj.item5 = v.E
							obj.item6 = v.F
							arr.push(obj)
						})
						_this.ruleForm.DISPERSIONtab = [...arr]
					} else if (_this.type == "2") { 

						outdata.map((v) => {
							let obj = {}
							obj.index = v.扩散距离
							obj.sionitem1 = v.A
							obj.sionitem2 = v.B
							obj.sionitem3 = v.C
							obj.sionitem4 = v.D
							obj.sionitem5 = v.E
							obj.sionitem6 = v.F
							arr.push(obj)
						})
						_this.ruleForm.DIST_DISTANCEtab = [...arr]
					} else if (_this.type == 3) {
						outdata.map((v) => {
							let obj = {}
							obj.index = v.Y方向扩散距离
							obj.SIGYitem1 = v.A
							obj.SIGYitem2 = v.B
							obj.SIGYitem3 = v.C
							obj.SIGYitem4 = v.D
							obj.SIGYitem5 = v.E
							obj.SIGYitem6 = v.F
							arr.push(obj)
						})
						_this.ruleForm.DIST_SIGYtab = [...arr]
					} else if (_this.type == 4) {
						outdata.map((v) => {
							let obj = {}
							obj.index = v.Z方向扩散距离
							obj.SIGitem1 = v.A
							obj.SIGitem2 = v.B
							obj.SIGitem3 = v.C
							obj.SIGitem4 = v.D
							obj.SIGitem5 = v.E
							obj.SIGitem6 = v.F
							arr.push(obj)
						})
						_this.ruleForm.DIST_SIGZtab = [...arr]
					}
 
				}
				reader.readAsArrayBuffer(f)
			}
			if (rABS) {
				reader.readAsArrayBuffer(f)
			} else {
				reader.readAsBinaryString(f)
			}
		},
		daoru(val) { 
			this.type = val 
			if (val == 1) {
				this.$refs.file1.click()
			} else if (val == 2) {
				this.$refs.file2.click()
			} else if (val == 3) {
				this.$refs.file3.click()
			} else if (val == 4) {
				this.$refs.file4.click()
			}
		},
		DISPERSIONChange() { 
			if (this.ruleForm.DISPERSION == 0) {
				// this.ruleForm.DISPERSIONtab = [
				// 	{
				// 		name: "σy线性因子",
				// 		type: "DPCYSIGA",
				// 		item1: 0.3658,
				// 		item2: 0.2751,
				// 		item3: 0.2089,
				// 		item4: 0.1474,
				// 		item5: 0.1046,
				// 		item6: 0.0722,
				// 	},
				// 	{
				// 		name: "σy指数因子",
				// 		type: "DPCYSIGB",
				// 		item1: 0.9031,
				// 		item2: 0.9031,
				// 		item3: 0.9031,
				// 		item4: 0.9031,
				// 		item5: 0.9031,
				// 		item6: 0.9031,
				// 	},
				// 	{
				// 		name: "σx线性因子",
				// 		type: "DPCZSIGA",
				// 		item1: 2.5e-4,
				// 		item2: 1.9e-3,
				// 		item3: 0.2,
				// 		item4: 0.3,
				// 		item5: 0.4,
				// 		item6: 0.2,
				// 	},
				// 	{
				// 		name: "σz指数因子",
				// 		type: "DPCZSIGB",
				// 		item1: 2.125,
				// 		item2: 1.6021,
				// 		item3: 0.8543,
				// 		item4: 0.6532,
				// 		item5: 0.6021,
				// 		item6: 0.602,
				// 	},
				// ]
				this.ruleForm.DISPERSIONtab = [
					{
						name: "σy线性因子",
						type: "DPCYSIGA",
						item1: "",
						item2: "",
						item3: "",
						item4: "",
						item5: "",
						item6: "",
					},
					{
						name: "σy指数因子",
						type: "DPCYSIGB",
						item1: "",
						item2: "",
						item3: "",
						item4: "",
						item5: "",
						item6: "",
					},
					{
						name: "σx线性因子",
						type: "DPCZSIGA",
						item1: "",
						item2: "",
						item3: "",
						item4: "",
						item5: "",
						item6: "",
					},
					{
						name: "σz指数因子",
						type: "DPCZSIGB",
						item1: "",
						item2: "",
						item3: "",
						item4: "",
						item5: "",
						item6: "",
					},
				]
				this.basic_Data.DPCYSIGA.forEach((item, index) => {
					let n = index + 1
					this.ruleForm.DISPERSIONtab[0]["item" + n] = item
				})
				this.basic_Data.DPCYSIGB.forEach((item, index) => {
					let n = index + 1
					this.ruleForm.DISPERSIONtab[1]["item" + n] = item
				})
				this.basic_Data.DPCZSIGA.forEach((item, index) => {
					let n = index + 1
					this.ruleForm.DISPERSIONtab[2]["item" + n] = item
				})
				this.basic_Data.DPCZSIGB.forEach((item, index) => {
					let n = index + 1
					this.ruleForm.DISPERSIONtab[3]["item" + n] = item
				})
			
				this.ruleForm.DIST_SIGYtab = []
				this.ruleForm.DIST_SIGZtab = []
				this.ruleForm.DIST_DISTANCEtab = []
			} else if (this.ruleForm.DISPERSION == 1) {
				this.ruleForm.DISPERSIONtab = []
				this.ruleForm.NUM_DIST001 = this.basic_Data.NUM_DIST001
				this.ruleForm.DIST_DISTANCEtab = []
				this.ruleForm.DIST_SIGYtab = []
				this.ruleForm.DIST_SIGZtab = []
				for (
					let index = 1;
					index <= parseInt(this.basic_Data.NUM_DIST001);
					index++
				) {
					let tempdata = {
						index: index,
						sionitem1: "",
						sionitem2: "",
						sionitem3: "",
						sionitem4: "",
						sionitem5: "",
						sionitem6: "",
					}
					this.ruleForm.DIST_DISTANCEtab.push(tempdata)
					let tempdata2 = {
						index: index,
						SIGYitem1: "",
						SIGYitem2: "",
						SIGYitem3: "",
						SIGYitem4: "",
						SIGYitem5: "",
						SIGYitem6: "",
					}
					let tempdata3 = {
						index: index,
						SIGitem1: "",
						SIGitem2: "",
						SIGitem3: "",
						SIGitem4: "",
						SIGitem5: "",
						SIGitem6: "",
					}
					this.ruleForm.DIST_SIGYtab.push(tempdata2)
					this.ruleForm.DIST_SIGZtab.push(tempdata3)
				} 

				this.basic_Data.DIST_DISTANCE.forEach((item, index) => {
				
					let i = index + 1
					item.forEach((it, n) => {
						this.ruleForm.DIST_DISTANCEtab[n][
							"sionitem" + i
						] = it.toString()
					})
				})

				this.basic_Data.DIST_SIGY.forEach((item, index) => {
					let i = index + 1
					item.forEach((it, n) => {
						this.ruleForm.DIST_SIGYtab[n][
							"SIGYitem" + i
						] = it.toString()
					})
				})

				this.basic_Data.DIST_SIGZ.forEach((item, index) => {
					let i = index + 1
					item.forEach((it, n) => {
						this.ruleForm.DIST_SIGZtab[n][
							"SIGitem" + i
						] = it.toString()
					})
				})
			}
		},
		NUM_DIST001Change() {
			this.ruleForm.DIST_DISTANCEtab = []
			this.ruleForm.DIST_SIGYtab = []
			this.ruleForm.DIST_SIGZtab = []
			for (
				let index = 1;
				index <= parseInt(this.ruleForm.NUM_DIST001);
				index++
			) {
				let tempdata = {
					index: index,
					sionitem1: "",
					sionitem2: "",
					sionitem3: "",
					sionitem4: "",
					sionitem5: "",
					sionitem6: "",
				}
				this.ruleForm.DIST_DISTANCEtab.push(tempdata)
				let tempdata2 = {
					index: index,
					SIGYitem1: "",
					SIGYitem2: "",
					SIGYitem3: "",
					SIGYitem4: "",
					SIGYitem5: "",
					SIGYitem6: "",
				}
				let tempdata3 = {
					index: index,
					SIGitem1: "",
					SIGitem2: "",
					SIGitem3: "",
					SIGitem4: "",
					SIGitem5: "",
					SIGitem6: "",
				}
				this.ruleForm.DIST_SIGYtab.push(tempdata2)
				this.ruleForm.DIST_SIGZtab.push(tempdata3)
			}
		},
		submitFun() {
			this.$refs.form.validate((valid) => {
				if (valid) {
					let tempdata = JSON.parse(JSON.stringify(this.basic_Data))
					tempdata.DISPERSION = parseInt(this.ruleForm.DISPERSION)
					if (tempdata.DISPERSION == 0) {
						let tempDPCYSIGA = []
						for (const key in this.ruleForm.DISPERSIONtab[0]) {
							if (
								this.ruleForm.DISPERSIONtab[0].hasOwnProperty(
									key
								)
							) {
								const element = this.ruleForm.DISPERSIONtab[0][
									key
								]
								
								tempDPCYSIGA.push(parseFloat(element))
								
							}
						}
						tempDPCYSIGA.splice(0, 2)
						let tempDPCYSIGB = []
						for (const key in this.ruleForm.DISPERSIONtab[1]) {
							if (
								this.ruleForm.DISPERSIONtab[1].hasOwnProperty(
									key
								)
							) {
								const element = this.ruleForm.DISPERSIONtab[1][
									key
								]
								
								tempDPCYSIGB.push(parseFloat(element))
								
							}
						}
						tempDPCYSIGB.splice(0, 2)
						let tempDPCZSIGA = []
						for (const key in this.ruleForm.DISPERSIONtab[2]) {
							if (
								this.ruleForm.DISPERSIONtab[2].hasOwnProperty(
									key
								)
							) {
								const element = this.ruleForm.DISPERSIONtab[2][
									key
								]
							
								tempDPCZSIGA.push(parseFloat(element))
								
							}
						}
						tempDPCZSIGA.splice(0, 2)
						let tempDPCZSIGB = []
						for (const key in this.ruleForm.DISPERSIONtab[3]) {
							if (
								this.ruleForm.DISPERSIONtab[3].hasOwnProperty(
									key
								)
							) {
								const element = this.ruleForm.DISPERSIONtab[3][
									key
								]

								tempDPCZSIGB.push(parseFloat(element))
							}
						}
						tempDPCZSIGB.splice(0, 2)
					

						tempdata.DPCYSIGA = tempDPCYSIGA
						tempdata.DPCYSIGB = tempDPCYSIGB
						tempdata.DPCZSIGA = tempDPCZSIGA
						tempdata.DPCZSIGB = tempDPCZSIGB

						tempdata.NUM_DIST001 = 0
						tempdata.DIST_DISTANCE = []
						tempdata.DIST_SIGZ = []
						tempdata.DIST_SIGY = []
					} else if (tempdata.DISPERSION == 1) {
						tempdata.NUM_DIST001 = parseInt(
							this.ruleForm.NUM_DIST001
						)
						let tempDIST_DISTANCE = []
						for (let index = 1; index <= 6; index++) {
							let obj = this.ruleForm.DIST_DISTANCEtab.map(
								(item) => {
									return parseFloat(item["sionitem" + index])
								}
							)
							tempDIST_DISTANCE.push(obj)
						}

						let tempDIST_SIGY = []
						for (let index = 1; index <= 6; index++) {
							let obj = this.ruleForm.DIST_SIGYtab.map((item) => {
								return parseFloat(item["SIGYitem" + index])
							})
							tempDIST_SIGY.push(obj)
						}

						let tempDIST_SIGZ = []
						for (let index = 1; index <= 6; index++) {
							let obj = this.ruleForm.DIST_SIGZtab.map((item) => {
								return parseFloat(item["SIGitem" + index])
							})
							tempDIST_SIGZ.push(obj)
						}

						tempdata.DIST_DISTANCE = tempDIST_DISTANCE
						tempdata.DIST_SIGZ = tempDIST_SIGZ
						tempdata.DIST_SIGY = tempDIST_SIGY

						tempdata.DPCYSIGA = []
						tempdata.DPCYSIGB = []
						tempdata.DPCZSIGA = []
						tempdata.DPCZSIGB = []
					}

					tempdata.DPYSCALE001 = parseFloat(this.ruleForm.DPYSCALE001)
					tempdata.DPZSCALE001 = parseFloat(this.ruleForm.DPZSCALE001)
					tempdata.SETPAGEINDEX = this.activeTab
					this.$store.dispatch("upData_basic_Data", tempdata) 
					let params = {
						batchid: this.$props.batchid,
						batchinfo: "BASE",
						submitjson: JSON.stringify(tempdata),
					}
					this.$appApi
						.BATCH_SUBMIT(params)
						.then((res) => {
							var str = res.data.substring(0, 1)
							if (str == "E") {
								let message = res.data.substring(6)
								this.$notify.error({
									title: "保存失败！",
									message: message,
									type: "success",
								})
							} else if (str == "S") {
								this.$notify({
									message: "保存成功！",
									type: "success",
								})
								this.$emit("changeActiveTab", this.activeTab)
					            this.$store.dispatch("change_basic_showTab", this.activeTab)
								if(activeTab >=9){
									this.$router.push({
										path: "/home",
									})
								}
							}
						})
						.catch((err) => {
							console.log(err)
						})
				}
			})
		},
	},
}
</script>
<style lang="scss" scoped>
.page-flex-row /deep/ .el-collapse-item__header {
	background: #f3f9fe;
}
.operation {
	width: 95%;
	height: 80px;
	display: flex;
	justify-content: flex-end;
	align-items: center;
}
#img-upload {
	display: none;
}
</style>